require 'statistic/html_fields_counter'
require "rexml/document"

module Statistic
  
  class FlickrFieldsCounter < HTMLFieldsCounter
    public
    
    def initialize( crawl_table, conditions = "status = 200" )
      super crawl_table, conditions
    end
    
    
    def analyse_html(xml_tree)
      
      #tutte le informazzioni eccotto dove si trova daesso 
      matchs = REXML::XPath.match xml_tree, "/html/body/div[@id='Main']/div/div[@id='col-container']/div[@id='side-col']/div[@id='a-bit-more-about']/dl/dt[text() != 'Currently:']"
      matchs.each {|e| @fields_stat[e.text.chomp(":").downcase] += 1 }
      
      #le informazioni su dove si trova adesso
      matchs = REXML::XPath.match xml_tree, "/html/body/div[@id='Main']/div/div[@id='col-container']/div[@id='side-col']/div[@id='a-bit-more-about']/dl/dd/span/span"
      matchs.each {|e| @fields_stat[e.attribute(:class).value] += 1}

    end
  end
  
  
end # module Statistic